#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int d[N],v[N],a[N],p[N];
bool vis[N];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t,n,m,l,v0;
    scanf("%d",&t);
    while(t--){
        memset(d,0,sizeof(d));
        memset(v,0,sizeof(v));
        memset(a,0,sizeof(a));
        memset(p,0,sizeof(p));
        memset(vis,false,sizeof(vis));
        scanf("%d %d %d %d",&n,&m,&l,&v0);
        for(int i=1;i<=n;i++){
            scanf("%d %d %d",&d[i],&v[i],&a[i]);
        }
        for(int i=1;i<=m;i++){
            scanf("%d",&p[i]);
        }
        int cnt=0,ans=0;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(p[j]<d[i]) continue;
                int vv=v[i]*v[i]+2*(p[j]-d[i])*a[i];
                if(vv>v0*v0){
//                    cout<<vv<<" "<<i<<" "<<j<<endl;
                    cnt++;
                    if(!vis[j]){
                        vis[j]=true;
                        ans++;
                    }
                    break;
                }
            }
        }
        printf("%d %d\n",cnt,m-ans);
    }
    return 0;
}
